﻿using Serialization.Script;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using GlobalGameClasses;
using Serialization;

namespace SirianTestEnvironment
{
    
    
    /// <summary>
    ///This is a test class for PathTest and is intended
    ///to contain all PathTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PathTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        [ClassCleanup()]
        public static void MyClassCleanup()
        {
            GlobalGameValues.Values.achievementsUnlocked = new List<Achievement>();
            GlobalGameValues.Values.content = new ContentCollection();
            GlobalGameValues.Values.difficulty = null;
            GlobalGameValues.Values.errorWriter = null;
            GlobalGameValues.Values.gameTime = new GameTime();
            GlobalGameValues.Values.GlobalStrings = new StringContainer();
            GlobalGameValues.Values.graphicsDevice = null;
            GlobalGameValues.Values.score = new InterfaceComponents.HUDWrapper<int>(new List<InterfaceComponents.HUDComponent>());
            GlobalGameValues.Values.soundPlayer = null;
            GlobalGameValues.Values.spriteBatch = null;
            GlobalGameValues.Values.volume_Music = 0;
            GlobalGameValues.Values.volume_soundEffect = 0;
        }
        //
        #endregion


        /// <summary>
        ///A test for moveStartPoint
        ///</summary>
        [TestMethod()]
        public void moveStartPointTest()
        {
            List<Vector2> pathPoints = new List<Vector2>();
            pathPoints.Add(new Vector2(0, 0));
            pathPoints.Add(new Vector2(20, 0));
            Path target = new Path(pathPoints); // TODO: Initialize to an appropriate value
            Vector2 point = new Vector2(100,100); // TODO: Initialize to an appropriate value
            target.moveStartPoint(point);
            Vector2 nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 100f && nextPoint.Y == 100f);
            nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 20f && nextPoint.Y == 0f);
        }

        /// <summary>
        ///A test for moveAllPoints
        ///</summary>
        [TestMethod()]
        public void moveAllPointsTest()
        {
            List<Vector2> pathPoints = new List<Vector2>();
            pathPoints.Add(new Vector2(0, 0));
            pathPoints.Add(new Vector2(20, 0));
            Path target = new Path(pathPoints); // TODO: Initialize to an appropriate value
            Vector2 point = new Vector2(100, 100); // TODO: Initialize to an appropriate value
            target.moveAllPoints(point);
            Vector2 nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 100f && nextPoint.Y == 100f);
            nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 120f && nextPoint.Y == 100f);
        }

        /// <summary>
        ///A test for isFinished
        ///</summary>
        [TestMethod()]
        public void isFinishedTest()
        {
            List<Vector2> pathPoints = new List<Vector2>();
            pathPoints.Add(new Vector2(0, 0));
            pathPoints.Add(new Vector2(20, 0));
            Path target = new Path(pathPoints); // TODO: Initialize to an appropriate value
            Vector2 point = new Vector2(100, 100); // TODO: Initialize to an appropriate value
            target.moveStartPoint(point);
            Vector2 nextPoint = target.getNextDestination();
            Assert.IsFalse(target.isFinished());
            nextPoint = target.getNextDestination();
            Assert.IsTrue(target.isFinished());
        }

        /// <summary>
        ///A test for getNextDestination
        ///</summary>
        [TestMethod()]
        public void getNextDestinationTest()
        {
            List<Vector2> pathPoints = new List<Vector2>();
            pathPoints.Add(new Vector2(0, 0));
            pathPoints.Add(new Vector2(20, 0));
            Path target = new Path(pathPoints);
            Vector2 nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 0 && nextPoint.Y == 0);
            nextPoint = target.getNextDestination();
            Assert.IsTrue(nextPoint.X == 20 && nextPoint.Y == 0);
        }
    }
}
